﻿#include <iostream>

static void printSubStr(char* str, size_t fullSize, int index)
{
    if (index >= fullSize)
    {
        char* tmp = (char*)malloc(fullSize + 1);
        memset(tmp, 0, fullSize + 1);
        int iTmp = 0;
        for (int i = 0; i < fullSize; i++)
        {
            if (!str[i]) continue;

            tmp[iTmp++] = str[i];
        }

        printf("%s\n", tmp);
        free(tmp);
        return;
    }

    char cur = str[index];
    str[index] = 0;
    printSubStr(str, fullSize, index + 1);
    str[index] = cur;
    printSubStr(str, fullSize, index + 1);
}

// 打印一个字符串的全部子序列, 包括空字符串
int main_SubsequenceOfString()
{
    char str[100] = "abc";
    printSubStr(str, strlen(str), 0);
    return 0;
}